/**
 * Created by wdj on 16/4/21.
 * webpack.config
 */
// var webpack = require('webpack');
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
var UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin');;
// var commonsPlugin = new webpack.optimize.CommonsChunkPlugin('common.js');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

var path = require('path');

module.exports = {
    entry: {
        vendor: [
            'Framework7',
            './src/libs/framework7.ext.js',
            'utils',
            'hybrid',
            'eruda'
        ],
        app: ['./src/js/app.js']
    },
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'js/[name].js'
    },
    module: {
        loaders: [
            {
                test: /\.js?$/,
                exclude: /(node_modules|bower_components)/,
                loader: 'babel?presets[]=es2015',
                include: path.join(__dirname, 'src')
            },
            { test: /\.(svg|png|jpg|gif|eot|ttf|woff)?$/, loader: 'file-loader?name=asset/[name].[ext]'},
            { test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") },
            { test: /\.jade$/, loader: 'jade'},
            { test: /\.json/, loader: 'json-loader'},
        ]
    },
    externals: {
        framework7: 'Framework7',
    },
    resolve: {
        alias: {
            utils: path.join(__dirname, 'src/libs/utils.js'),
            hybrid: path.join(__dirname, 'src/libs/hybrid.js'),
        }
    },
    plugins: [
        new CommonsChunkPlugin(['vendor'],'common.js'),
        new ExtractTextPlugin("style.css"),
        new HtmlWebpackPlugin({
            title: 'Webpack App',
            template: './src/index.html'
        }),
        /*new UglifyJsPlugin({
            compress: {
                warnings: false
            }
        })*/
    ]
};

